load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "gossip",
    srcs = [
        "client.go",
        "doc.go",
        "gossip.go",
        "info.go",
        "infostore.go",
        "keys.go",
        "node_set.go",
        "server.go",
        "status.go",
        "util.go",
    ],
    embed = [":gossip_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/gossip",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/config",
        "//pkg/kv/kvpb",
        "//pkg/roachpb",
        "//pkg/rpc",
        "//pkg/rpc/nodedialer",
        "//pkg/util",
        "//pkg/util/errorutil",
        "//pkg/util/grpcutil",
        "//pkg/util/hlc",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/protoutil",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_cockroachdb_redact//:redact",
    ],
)

go_test(
    name = "gossip_test",
    size = "small",
    srcs = [
        "client_test.go",
        "convergence_test.go",
        "gossip_test.go",
        "info_test.go",
        "infostore_test.go",
        "keys_test.go",
        "main_test.go",
        "node_set_test.go",
        "status_test.go",
        "storage_test.go",
        "util_test.go",
    ],
    embed = [":gossip"],
    deps = [
        "//pkg/base",
        "//pkg/config",
        "//pkg/config/zonepb",
        "//pkg/gossip/simulation",
        "//pkg/roachpb",
        "//pkg/rpc",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/testutils",
        "//pkg/testutils/skip",
        "//pkg/util",
        "//pkg/util/hlc",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/netutil",
        "//pkg/util/protoutil",
        "//pkg/util/randutil",
        "//pkg/util/retry",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_stretchr_testify//require",
        "@org_golang_google_grpc//:go_default_library",
    ],
)

proto_library(
    name = "gossip_proto",
    srcs = ["gossip.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb:roachpb_proto",
        "//pkg/util:util_proto",
        "//pkg/util/hlc:hlc_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "gossip_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_grpc_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/gossip",
    proto = ":gossip_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb",
        "//pkg/util",
        "//pkg/util/hlc",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)
